#include "pch.h"


void GameSceneContactListener::PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
{

}

GameSceneContactListener* GameScene::GetContactListener()
{
	return &m_ContactListener;
}


GameScene::GameScene()
{

}

GameScene::~GameScene()
{
}

void GameScene::Initialize()
{
	m_Ground = std::shared_ptr<Ground>(new Ground());
	m_Ground->Initialize();
	DirectX2DRender::Instance()->GetCurrentCamera()->SetPosition(float3(0.f, 13.f, 30.f));
}

bool GameScene::ParseRobot(const char* xml, uint length)
{
	tinyxml2::XMLDocument doc;
	tinyxml2::XMLError error = doc.Parse(xml, length);
	if(error != tinyxml2::XML_NO_ERROR)
		return false;

	tinyxml2::XMLHandle docHandle(&doc);
	tinyxml2::XMLElement *robot_node = docHandle.FirstChildElement(XML_ROBOT).ToElement();

	m_Robot1P = RobotManager::Instance()->CreateRobot();
	m_Robot1P->SetCorePosition(float2(0.f, 15.f));

	m_Robot1P->LoadParts(robot_node, false);
	m_Robot1P->Initialize();
	return true;
}

void GameScene::CreateRobotPart()
{
	
}

void GameScene::GameStart()
{
	if(m_Robot1P)
	{
		m_Robot1P->Reset();
		//m_Robot1P->Active();
	}


	if(m_Robot2P)
	{
		m_Robot2P->Reset();
	}
}

void GameScene::GameEnd()
{

}

void GameScene::OnUpdate(float frameTime)
{
	if(m_Ground)
		m_Ground->OnUpdate(frameTime);
}

void GameScene::OnPreRender()
{
	if(m_Ground)
		m_Ground->OnPreRender();
}
